//
//  ModifyPasswordViewController.m
//  联付商圈
//
//  Created by apple on 2017/10/31.
//  Copyright © 2017年 lianfu. All rights reserved.
//

#import "ModifyPasswordViewController.h"
#import "LTView.h"

@interface ModifyPasswordViewController ()
///原密码
@property (nonatomic, strong) LTView *oldPasswordView;
///新密码
@property (nonatomic, strong) LTView *passwordView;
///确认新密码
@property (nonatomic, strong) LTView *surePasswordView;
@end

@implementation ModifyPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self buildMainInterface];
    NSLog(@"%ld", self.payOrLogin);
}

- (void)buildMainInterface
{
    NSString *title = @"";
    if (self.payOrLogin == 0) {
        title = @"重置登录密码";
    } else {
        title = @"重置支付密码";
    }
    [self.navigationItem setTitle:title];
    
    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"modifyPassword@2x"]];
    imgView.frame = CGRectMake(22 * FONTSIZE, 64 + 19 * FONTSIZE, SCREENW - 44 * FONTSIZE, 289 * FONTSIZE);
    imgView.userInteractionEnabled = YES;
    [self.view addSubview:imgView];
    
    self.oldPasswordView = [[LTView alloc] initWithFrame:CGRectMake(14 * FONTSIZE, 1 * FONTSIZE, imgView.frame.size.width - 14 * FONTSIZE, 46 * FONTSIZE)];
    self.oldPasswordView.titleLabel.text = @"原密码";
    self.oldPasswordView.textField.placeholder = @"请输入您的原密码";
    self.oldPasswordView.textField.secureTextEntry = YES;
    [imgView addSubview:_oldPasswordView];

    
    self.passwordView = [[LTView alloc] initWithFrame:CGRectMake(14 * FONTSIZE, self.oldPasswordView.frame.origin.y + self.oldPasswordView.frame.size.height, imgView.frame.size.width - 14 * FONTSIZE, 46 * FONTSIZE)];
    self.passwordView.titleLabel.text = @"新密码";
    self.passwordView.textField.placeholder = @"请设置您的新密码";
    self.passwordView.textField.secureTextEntry = YES;
    [imgView addSubview:_passwordView];
    
    self.surePasswordView = [[LTView alloc] initWithFrame:CGRectMake(14 * FONTSIZE, self.passwordView.frame.origin.y + self.passwordView.frame.size.height, imgView.frame.size.width - 14 * FONTSIZE, 46 * FONTSIZE)];
    self.surePasswordView.titleLabel.text = @"确认密码";
    self.surePasswordView.textField.placeholder = @"请确认您的新密码";
    self.surePasswordView.textField.secureTextEntry = YES;
    [imgView addSubview:_surePasswordView];
    
    UIButton *sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [sureButton.titleLabel setFont:[UIFont systemFontOfSize:14 * FONTSIZE]];
    [sureButton setTitle:@"确定" forState:UIControlStateNormal];
    [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sureButton.layer.backgroundColor = MAINCOLOR.CGColor;
    sureButton.layer.cornerRadius = 5;
    [imgView addSubview:sureButton];
    [sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView.mas_left).offset(27 * FONTSIZE);
        make.right.equalTo(imgView.mas_right).offset(-27 * FONTSIZE);
        make.bottom.equalTo(imgView.mas_bottom).offset(-22 * FONTSIZE);
        make.height.mas_equalTo(40 * FONTSIZE);
    }];
    
    UITapGestureRecognizer *receiveKeyboardTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(receiveKeyboard)];
    [self.view addGestureRecognizer:receiveKeyboardTap];
}

- (void)receiveKeyboard
{
    [self.oldPasswordView.textField resignFirstResponder];
    [self.passwordView.textField resignFirstResponder];
    [self.surePasswordView.textField resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
